package cn.sccdlg.fzmybatis.mybatis2sx.cfg;

import java.util.HashMap;
import java.util.Map;

/**
 * @author RaoShuang
 * @emil 991207823@qq.com
 * @date 2020/10/11 21:55
 * mybatis自实现之自定义mybatis的配置类
 *      主要是连接mysql的加载类、mysql访问地址、mysql用户名和密码
 */
public class Configuration {
    /**
     * 连接类名(全限定类名)
     */
    private String driver;
    /**
     * mysql数据库连接地址信息
     */
    private String url;
    /**
     * 用户名
     */
    private String username;
    /**
     * 用户密码
     */
    private String password;

    /**
     * 定义存储关系映射对的容器
     */
    private Map<String,Mapper> mappers = new HashMap<>();

    /**
     * 获取容器所有的关系映射对
     */
    public Map<String, Mapper> getMappers() {
        return mappers;
    }

    public void setMappers(Map<String, Mapper> mappers) {
        //此处需要使用追加的方式
        this.mappers.putAll(mappers);
    }

    public String getDriver() {
        return driver;
    }

    public void setDriver(String driver) {
        this.driver = driver;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "Configuration{" +
                "driver='" + driver + '\'' +
                ", url='" + url + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", mappers=" + mappers +
                '}';
    }
}
